'''
@author: Aurelien Deharbe


This file is part of Cute-Server.

Cute-Server is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Cute-Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Cute-Server.  If not, see <http://www.gnu.org/licenses/>.
'''

from PySide.QtCore import QThread
import time

class CTimeout(QThread):
    
    def __init__(self, timeout):
        QThread.__init__(self)
        self._timeout = timeout
        self._expired = False
        self._cont = True
    
    def run(self):
        count = 0
        while self._cont and count < self._timeout:
            time.sleep(1)
            count = count + 1
        self._expired = True

    def quit(self):
        self._cont = False
        
    def isExpired(self):
        return self._expired
        
        
        

if __name__ == '__main__':
    print "Please use the cuteserver script to run it"
